package app.server.project.main.service.db.dao;

import app.server.project.core.constants.Def;
import app.server.project.main.service.db.entity.AccountEntity;
import app.server.project.main.service.db.entity.DeviceBaseEntity;
import app.server.project.main.service.db.mapper.AccountMapper;
import app.server.project.main.service.db.mapper.DeviceBaseMapper;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;

import java.util.Objects;

/**
 * @author Administrator
 * @description 针对表【user_info(用户信息表)】的数据库操作Service实现
 * @createDate 2025-01-16 15:25:22
 */
@Repository
public class DeviceBaseDao extends ServiceImpl<DeviceBaseMapper, DeviceBaseEntity> {


    @Cacheable
    public DeviceBaseEntity getDataById(long deviceId) {
        var data=this.getById(deviceId);
        if (Objects.isNull(data)){
            //缓存没有,就往库中写入一条数据
            data=DeviceBaseEntity.of();
        }
        return data;
    }
}




